/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "users")
@NamedQueries({@NamedQuery(name = "User.findByUserID", query = "SELECT u FROM User u WHERE u.userID = :userID"), @NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"), @NamedQuery(name = "User.findByDisplayName", query = "SELECT u FROM User u WHERE u.displayName = :displayName"), @NamedQuery(name = "User.findByPwd", query = "SELECT u FROM User u WHERE u.pwd = :pwd"), @NamedQuery(name = "User.findByAccountStatus", query = "SELECT u FROM User u WHERE u.accountStatus = :accountStatus"), @NamedQuery(name = "User.findByUserPrivacy", query = "SELECT u FROM User u WHERE u.userPrivacy = :userPrivacy"), @NamedQuery(name = "User.findByCreationDate", query = "SELECT u FROM User u WHERE u.creationDate = :creationDate"), @NamedQuery(name = "User.findByLastUpdatedDate", query = "SELECT u FROM User u WHERE u.lastUpdatedDate = :lastUpdatedDate")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id 
    @GeneratedValue
    @Column(name = "userID", nullable = false)
    private Integer userID;
    @Column(name = "email", nullable = false)
    private String email;
    @Column(name = "displayName")
    private String displayName;
    @Column(name = "pwd")
    private String pwd;
    @Column(name = "accountStatus")
    private String accountStatus;
    @Column(name = "userPrivacy")
    private String userPrivacy;
    @Column(name = "creationDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationDate;
    @Column(name = "lastUpdatedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdatedDate;
    @JoinColumn(name = "userLevelId", referencedColumnName = "userLevelId")
    @ManyToOne
    private UserLevel userLevelId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userID")
    private Collection<Post> postsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<VoteResult> voteresultsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userID")
    private Collection<Feedback> feedbackCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<UserLogin> userloginsCollection;
                @OneToMany(mappedBy = "userId")
    private Collection<Comment> commentsCollection;

    public User() {
    }

    public User(Integer userID) {
        this.userID = userID;
    }

    public User(Integer userID, String email) {
        this.userID = userID;
        this.email = email;
    }

    public Integer getUserID() {
        return userID;
    }

    public void setUserID(Integer userID) {
        this.userID = userID;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getAccountStatus() {
        return accountStatus;
    }

    public void setAccountStatus(String accountStatus) {
        this.accountStatus = accountStatus;
    }

    public String getUserPrivacy() {
        return userPrivacy;
    }

    public void setUserPrivacy(String userPrivacy) {
        this.userPrivacy = userPrivacy;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public Date getLastUpdatedDate() {
        return lastUpdatedDate;
    }

    public void setLastUpdatedDate(Date lastUpdatedDate) {
        this.lastUpdatedDate = lastUpdatedDate;
    }

    public UserLevel getUserLevelId() {
        return userLevelId;
    }

    public void setUserLevelId(UserLevel userLevelId) {
        this.userLevelId = userLevelId;
    }

    public Collection<Post> getPostsCollection() {
        return postsCollection;
    }

    public void setPostsCollection(Collection<Post> postsCollection) {
        this.postsCollection = postsCollection;
    }

    public Collection<VoteResult> getVoteresultsCollection() {
        return voteresultsCollection;
    }

    public void setVoteresultsCollection(Collection<VoteResult> voteresultsCollection) {
        this.voteresultsCollection = voteresultsCollection;
    }

    public Collection<Feedback> getFeedbackCollection() {
        return feedbackCollection;
    }

    public void setFeedbackCollection(Collection<Feedback> feedbackCollection) {
        this.feedbackCollection = feedbackCollection;
    }

    public Collection<UserLogin> getUserloginsCollection() {
        return userloginsCollection;
    }

    public void setUserloginsCollection(Collection<UserLogin> userloginsCollection) {
        this.userloginsCollection = userloginsCollection;
    }

    public Collection<Comment> getCommentsCollection() {
        return commentsCollection;
    }

    public void setCommentsCollection(Collection<Comment> commentsCollection) {
        this.commentsCollection = commentsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userID != null ? userID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.userID == null && other.userID != null) || (this.userID != null && !this.userID.equals(other.userID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.User[userID=" + userID + "]";
    }

}
